from demo import test
from lib  import *

@eg
def chunked1():
  for x in chunks(list('abcd|fghi|klmn|pqrs|'),5):
    print x

@eg
def chunked2():
  for x in chunks([1,2,3],25):
    print x

@eg
def tiled():
  print tiles(range(1,100),20)

@test
def rowsed():
   return ( 
     [['a', 'b', '$c', 'd'], 
      ['1', '2', '3', '4'], 
      ['5', '6', '7', '8']
     ],
     [line for line in rows('data/test1.csv')])

@test
def oftened() :
  counts={}
  random.seed(1)
  for x in often([(1,10),(2,20),(3,40)],
                 max=10000,
                 item=first,weight=second):
    counts[x] = counts.get(x,0) + 1
  return {1: 1447, 2: 2883, 3: 5670},counts

@eg
def cuted():
  l=[0,0,0,0.99,0.99,0.99,
     0.99,1,1,1,1,1]
  print cut(l,cohen=0.3)
